﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GeekDesk
{
    public class GetHotPassege
    {
        public static List<string> title = new List<string>();
        public static List<string> content = new List<string>();
        public static List<string> summery = new List<string>();
        public static List<string> website = new List<string>();
        public GetHotPassege()
        {
            var path = @"D:\desktop\GeekDesk-master\Resource\HotPassageTtext\1.txt";
            var path1 = @"D:\desktop\GeekDesk-master\Resource\HotPassageTtext\0.txt";
            using (FileStream stream = File.Open(path1, FileMode.OpenOrCreate, FileAccess.Write))
            {
                stream.Seek(0, SeekOrigin.Begin);
                stream.SetLength(0);
            }
            string[] ReadText = File.ReadAllLines(path, Encoding.UTF8);
            foreach (string item in ReadText)
            {
                //Console.WriteLine(item);
                //if (item.Contains("content type") || item.Contains("title type") || item.Contains("summary type")|| item.Contains("link rel=\"alternate\" type=\"text/html\""))
                //{
                //    using (StreamWriter writer = new StreamWriter(path1, true))
                //    {

                //        writer.WriteLine(item.Replace(@"<title type=""text"">", ""));
                //    }
                //}
                if (item.Contains("content type"))
                {
                    string m = item.Remove(1, 24);
                    string n = m.Replace(@"</content>", "");
                    content.Add(n);
                }
                else if (item.Contains("title type"))
                {

                    string m = item.Replace(@"<title type=""text"">", "");
                    string n = m.Replace(@"</title>", "");
                    string x = n.Replace(@"<subtitle type=""text"">", "");
                    string y = x.Replace(@"</subtitle>", "");
                    title.Add(y);

                }
                else if (item.Contains("summary type"))
                {

                    string m = item.Replace(@"<summary type=""text"">", "");
                    string n = m.Replace(@"</summary>", "");
                    summery.Add(n);
                }
                else if (item.Contains("link rel=\"alternate\" type=\"text/html\""))
                {

                    string m = item.Replace(@"<link rel=""alternate"" type=""text/html"" href=""", "");
                    string n = m.Replace(@""" />", "");
                    website.Add(n);
                }
            }
        }

        
    }
}
